<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:Apex.Controls"
    xmlns:converters="clr-namespace:Apex.Converters"
    xmlns:dragAndDrop="clr-namespace:Apex.DragAndDrop">

    <Style TargetType="{x:Type controls:ImageButton}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type controls:ImageButton}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>

                            <!-- The image for the normal state. -->
                            <Image 
                                x:Name="image"
                                Source="{TemplateBinding NormalImageSource}" Stretch="None" RenderOptions.BitmapScalingMode="Linear" 
                                Margin="{TemplateBinding Padding}" />
                        </Grid>                        
                    </Border>
                    
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsPressed" Value="True">
                            <Setter TargetName="image" Property="Source" Value="{Binding  RelativeSource={RelativeSource TemplatedParent},Path=PressedImageSource}" />
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter TargetName="image" Property="Source" Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=DisabledImageSource}" />
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter TargetName="image" Property="Source" Value="{Binding RelativeSource={RelativeSource TemplatedParent},Path=MouseOverImageSource}" />
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
